#ifndef ACTIONSETTINGSDIALOG_H
#define ACTIONSETTINGSDIALOG_H

#include <QAbstractItemModel>
#include <QDialog>
#include "action.h"
#include "actionitemview.h"
#include "layout.h"

namespace Ui {
class ActionSettingsDialog;
}

class ActionSettingsDialog : public QDialog
{
    Q_OBJECT

public:
    explicit ActionSettingsDialog(Layout *layout, Action *action, QWidget *parent = 0);
    ~ActionSettingsDialog();

    virtual void done(int r);

    void load(QString &xmlData);

private slots:
    void onButtonUpload();
    void onActionShowContextMenu(const QPoint& pos);
    void onActionMenuAdd();
    void onActionMenuEdit();
    void onActionMenuDel();

private:
    enum {
        ActionName=0,
        ActionStartTime,ActionStartAction,
        ActionEndTime,ActionEndAction,
        ActionDayOfWeek,
        ActionCid,ActionBid,ActionRid,ActionUuid,
        ActionColumn
    };

    void setupModel();
    void setupViews();

    QString timeString(QString time);
    QString actionString(int action);

private:
    Ui::ActionSettingsDialog *ui;

    Layout *mpLayout;
    Action *mpAction;

    QAbstractItemModel *mpActionModel;
    QTableView *mpActionView;
};

#endif // ACTIONSETTINGSDIALOG_H
